package com.funsport.dto.response;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@NoArgsConstructor
@Schema(description = "登录响应")
public class LoginResponse {
    @Schema(description = "JWT Token")
    private String token;
    
    @Schema(description = "用户信息")
    private UserInfo userInfo;
    
    @Schema(description = "角色列表（用于权限控制）")
    private List<String> roles;
    
    // 兼容旧版本的构造函数
    public LoginResponse(String token, Long userId, String role, String nickname, String avatar) {
        this.token = token;
        this.userInfo = new UserInfo();
        this.userInfo.setId(userId);
        this.userInfo.setRole(role);
        this.userInfo.setNickname(nickname);
        this.userInfo.setAvatar(avatar);
    }
    
    // 完整构造函数
    public LoginResponse(String token, UserInfo userInfo) {
        this.token = token;
        this.userInfo = userInfo;
    }
    
    /**
     * 用户信息内嵌类
     */
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class UserInfo {
        @Schema(description = "用户ID")
        private Long id;
        
        @Schema(description = "用户角色")
        private String role;
        
        @Schema(description = "昵称")
        private String nickname;
        
        @Schema(description = "头像")
        private String avatar;
        
        @Schema(description = "性别：0-未知，1-男，2-女")
        private Integer gender;
        
        @Schema(description = "手机号")
        private String phone;
        
        @Schema(description = "邮箱")
        private String email;
        
        @Schema(description = "城市")
        private String city;
        
        @Schema(description = "地区")
        private String district;
        
        @Schema(description = "个人简介")
        private String bio;
        
        @Schema(description = "运动偏好（JSON字符串）")
        private String sportsPreferences;
        
        @Schema(description = "技能水平")
        private String skillLevel;
        
        @Schema(description = "积分")
        private Integer points;
        
        @Schema(description = "等级")
        private Integer level;
    }
}
